package com.mid;

/**
 * Created by Lxk on 2020/1/30.
 */
public class Solution165 {

    public int compareVersion(String version1, String version2) {
        String[] numStrs = version1.split("\\.");
        String[] numStrs2 = version2.split("\\.");
        int i = 0;
        for (; i < Math.min(numStrs.length, numStrs2.length); i++) {
            Integer value = Integer.valueOf(numStrs[i]);
            Integer value2 = Integer.valueOf(numStrs2[i]);
            if (value > value2) {
                return 1;
            } else if (value < value2) {
                return -1;
            }
        }
        if (numStrs.length == numStrs2.length) {
            return 0;
        }
        for (; i < Math.max(numStrs.length, numStrs2.length); i++) {
            if (i >= numStrs.length && Integer.valueOf(numStrs2[i]) > 0) {
                return -1;
            } else if (i >= numStrs2.length && Integer.valueOf(numStrs[i]) > 0) {
                return 1;
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        Solution165 solution165 = new Solution165();
        System.out.println(solution165.compareVersion("0.1", "1.0"));
    }
}
